package com.demo.book_manage.Util;

import com.demo.book_manage.POJO.Result;

/**
 * Result类的工具类
 * @author 梁灿鑫
 * @since 2021-01-30
 */
public class ResultUtil {
    //有data返回的Result类的封装
    public static Result success(Object o){
        Result result = new Result();
        result.setCode(0);
        result.setMsg("成功");
        result.setData(o);
        return result;
    }

    //没有data返回的Result类的封装
    public static Result success(){
        return success(null);
    }

    //发生错误时返回的Result类的封装
    public static Result error(int code, String msg){
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
}
